package com.beone.smart.userCenter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beone.smart.userCenter.dao.SysUserInfoMapper;
import com.beone.smart.userCenter.model.entity.SystemUserInfoDO;
import com.beone.smart.userCenter.service.intf.SysUserInfoService;
import com.beone.smart.userCenter.utils.TicketKeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @Date: 2019/8/27
 * @Author: yangjie
 * desc:  系统级别用户service实现
 **/
@Service
public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SystemUserInfoDO> implements SysUserInfoService {
    @Autowired
    private TicketKeyUtil ticketKeyUtil;

    @Override
    public SystemUserInfoDO makeTicket(String origin) {
        SystemUserInfoDO systemUserInfoDO = new SystemUserInfoDO();
        systemUserInfoDO.setOrigin(origin);
        systemUserInfoDO.setCreate_time(LocalDateTime.now().toLocalDate().toString());
        //设置ticket
        systemUserInfoDO.setTicket_key(ticketKeyUtil.getMD5(origin));
        //
        save(systemUserInfoDO);
        return systemUserInfoDO;
    }
}
